﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ControlLibary
{
    public class TrackControl : System.Windows.Forms.Control
    {
        private Color backColor = Color.Transparent;
        public new Color BackColor
        {
            get { return backColor; }
            set { backColor = value; }
        }

        private Color borderColor = Color.DarkGray;
        public Color BorderColor
        {
            get { return borderColor; }
            set { borderColor = value; }
        }

        private Color trackBackColor = Color.FromArgb(192, 192, 192);
        public Color TrackBackColor
        {
            get { return trackBackColor; }
            set { trackBackColor = value; }
        }

        private Color trackBorderColor = Color.FromArgb(128, 128, 128);
        public Color TrackBorderColor
        {
            get { return trackBorderColor; }
            set { trackBorderColor = value; }
        }

        private float borderSize = 1f;
        public float BorderSize
        {
            get { return borderSize; }
            set { borderSize = value; }
        }

        private int min = 0;
        public int MinValue
        {
            get
            {
                return min;
            }
            set
            {
                min = value;
            }
        }

        private int max = 100;
        public int MaxValue
        {
            get
            {
                return max;
            }
            set
            {
                max = value;
            }
        }

        private int value;
        public int Value { get => value; set => this.value = value; }

        protected override void OnPaint(PaintEventArgs e)
        {
            Graphics g = e.Graphics;

            Rectangle rec = this.Bounds;

            //Fill BackGround
            using (SolidBrush sb = new SolidBrush(backColor))
            {
                g.FillRectangle(sb, rec);
            }

            //Draw BackBorder
            using (Pen p = new Pen(borderColor, borderSize))
            {
                g.DrawRectangle(p, rec);
            }

            //Fill TrackGround

            Rectangle rec_Track = new Rectangle(rec.X + 10, rec.Y + 10, rec.Width - 20, rec.Height - 20);

            using (SolidBrush sb = new SolidBrush(trackBackColor))
            {
                g.FillRectangle(sb, rec_Track);
            }

            //Draw TrackBorder
            using (Pen p = new Pen(trackBorderColor, borderSize))
            {
                g.DrawRectangle(p, rec_Track);
            }

            //Draw TrackBoxBorder

            //Fill TrackBox
        }
    }
}
